import { createRouter, createWebHistory } from 'vue-router';
import LoginPage from '../components/LoginPage.vue'; // 登录页面，目前该页面存在问题，没有进行正则表达校验
import Header from '../components/header.vue';//用于展示登录名称相关信息的页面，该页面已经无问题
import changePassword from '@/components/changePassword.vue';
import Administratorsheader from '../components/AdministratorsHeader.vue'
import HomePage from '@/components/homePage.vue';
import AlgorithmsMessage from '../components/algorithmsMessage.vue'
import AdministratorsHome from '@/components/AdministratorsHome.vue';
import AlgorithmConfiguration from '@/components/threeRouter/AlgorithmConfiguration.vue';
import AlgorithmicScenarios from '@/components/threeRouter/AlgorithmicScenarios.vue';
import UserManagement from '@/components/threeRouter/UserManagement.vue';
import LargeModel from '@/components/threeRouter/LargeModel.vue';
import BigModel from '@/components/BigModel.vue';
import component from 'element-plus/es/components/tree-select/src/tree-select-option.mjs';
const routes = [
  {
    path: '/',
    name: 'Header',
    component: Header,
    redirect: '/homePage',
    children: [
      {
        path: '/homePage',
        name: 'HomePage',
        component: HomePage
      },
      {
        path: '/algorithmsMessage',
        name: 'AlgorithmsMessage',
        component: AlgorithmsMessage

      },
      {
        path: '/bigModel',
        name: 'BigModel',
        component: BigModel
      },
    ]
  },
  { path: '/login', name: 'Login', component: LoginPage },
  { path: '/changePassword', name: 'changePassword', component: changePassword },
  {
    path: '/administratorsheader',
    name: 'Administratorsheader',
    component: Administratorsheader,
    redirect: '/administratorsHome',
    children: [
      {
        path: '/administratorsHome',
        name: 'AdministratorsHome',
        component: AdministratorsHome,
        redirect: '/algorithmConfiguration',
        children: [
          {
            path: '/algorithmConfiguration',
            name: 'AlgorithmConfiguration',
            component: AlgorithmConfiguration
          },
          {
            path: '/algorithmicScenarios',
            name: 'AlgorithmicScenarios',
            component: AlgorithmicScenarios
          },
          {
            path: '/userManagement',
            name: 'UserManagement',
            component: UserManagement
          },
          {
            path: '/largeModel',
            name: 'LargeModel',
            component: LargeModel
          },
        ]
      }
    ]
  },
];

const router = createRouter({
  history: createWebHistory(),
  routes,
});

// 全局路由守卫
// router.beforeEach((to, _from, next) => {
//   const isLoggedIn = localStorage.getItem('isLoggedIn') === 'true'; // 检查本地存储中的登录状态

//   if (to.meta.requiresAuth && !isLoggedIn) {
//     // 如果目标路由需要登录且用户未登录
//     alert('请先登录！');
//     next('/'); // 跳转到登录页面
//   } else {
//     next(); // 否则允许导航
//   }
// });

export default router;
